Day 4: Managing System Components

Localization

Setting system up to your region:

date - Print date in specified format

timedatectl - Set system date and time information

tzselect - Select timezone

dpkg-reconfigure tzdata - Configure timezone data on Debian systems

localectl - Configure system locale and keyboard layout settings


GUIs

Interacting with system through a visual design element

Types of GUIs:

Display Server

X Window System also known as X11 or X


SSH Port Forwarding

Tunneling any port over SSH

Reverse Tunnel masqueraded as SSL:
ssh -2NR 999:public_ip:443


Manage Services

Services: Software that responds to requests from other programs to provide specialized functionality.

Daemons: Services running in background that don't require human interaction. Lie dormant until called upon.

System Initialization

Loading of OS and components. Accomplished with init daemon

init - /etc/init.d

Run Levels: /etc/rc#.d

1 = Single-user
2 = Multi-user without networking
3 = Multi-user with networking
4 = Not used
5 = Loads desktop environment with networking
6 = Reboot

chkconfig --level <service> on/off


systemd
/etc/systemd/system/ = Links/copies
/lib/systemd/system/ = Actual files being linked

systemd:

systemd-anaylze blame - Identifty processes slowing down a system

systemctl: Instructs systemd what to do


NICE value

top - Displays NI value

nice wireshark - Start wireshark with nice value of 10 (lower priority)
nice -15 wireshark - Start wireshark with nice value of -15 (higher priority)

renice -n 15 <pid> - Set priority on a running process
renice -n 15 $(pgrep wireshark) - Grabs the pid of wireshark and sets nice value to 15

ctrl+z = pause program/command
jobs = list current programs/commands
bg <job#> = background job
fg <job#> = foreground job
nohup <command> = start command seperate from terminal control

kill -9 <pid>
pkill <name of process>
killall <name of process>

List all open files
lsof
lsof +d /dir/here - List open files in a specific directory

How long a system's been running
uptime

System usage reports
sar

Memory Statistics
free -h


Create 1GB of Swap Space
Creates 1G filew ith zeros
dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
swapon /swapfile
swapoff /swapfile


LAB

Change date/timezone
timedatectl list-timezones | grep \<country\>
timedatectl set-timezone \<timezone\>

Change locale / keyboard mapping
localectl status
localectl list-keymaps
localectl list-locale
localectl set-locale "LANG=en_US.utf8"
localectl set-keymap us

Setting up GUIs
From CLI: systemctl isolate graphical.target

Configuring target files
/usr/lib/systemd/system/<target.files> - Location of target files
systemctl --type=service = View current target's services
systemctl isolate multi-user.target = Switch to CLI only
systemctl set-default graphical.target = From CLI set GUI to be default environment.

systemctl status sshd.service - List SSH status
systemctl disable firewalld.service - Will disable firewall on startup but not effect the current running status

Process Management
top + M = Organize by memory usage
top + P = Organize by CPU usage

lsof = List files and who opened them
lsof -u student01 = See files opened by student01

systemd-analyze = Analyze the time it took to start the kernel, initrd, and userspace

systemd-analyze blame = Display slowest loaded processes

top + r = Renice

Dispaly CPU info
less /proc/cpuinfo

Display system information
sar -u
sar 2 6 = gather information every two seconds for 6 queries
sar -S = Gather swap space information

less /proc/meminfo = Display memory information
free -h = Display memory usage in human-readable format

vmstat -d 5 3 = Display virtual memory statistics per storage device